package com.vpclub;

import com.vpclub.aop.MathCalculator;
import com.vpclub.config.MainConfigOfAop;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author : leimingchao
 * @date Date : 2021年06月22日 21:44
 */
public class IOCTest_AOP {


    @Test
    public void test() {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfigOfAop.class);

        //1.不要自己创建对象
        // MathCalculator mathCalculator = new MathCalculator();
        // mathCalculator.div(1, 1);
        MathCalculator mathCalculator = applicationContext.getBean(MathCalculator.class);
        mathCalculator.div(1, 0);
        //容器关闭
        applicationContext.close();
    }
}
